package com.shilei.cor;

import com.shilei.GameObject;
import com.shilei.Tank;
import com.shilei.common.Group;

/**
 * @description: 坦克坦克碰撞
 * @author: 81271
 * @date: 2020-04-15 20:17
 */
public class TankTankCollider implements Collider {

    @Override
    public boolean collide(GameObject go1, GameObject go2) {
        if (go1 instanceof Tank && go2 instanceof Tank) {
            Tank tank1 = (Tank)go1;
            Tank tank2 = (Tank)go2;

            if (tank1.getRect().intersects(tank2.getRect())) {
                if (!Group.Good.equals(tank1.getGroup())) tank1.restoration();

                if (!Group.Good.equals(tank2.getGroup())) tank2.restoration();
            }
        }

        return false;


    }

}
